From e26e924557e591359a633c0f063bdc7f35e0bc34 Mon Sep 17 00:00:00 2001 From: Domas Mituzas Date: Sat, 5 May 2007 01:51:18 +0000 Subject: [PATCH] Use pl_from and tl_from for offsets/sorting, instead of secondary joined table field - avoids filesorts and temptables and whatever else. --- includes/SpecialWhatlinkshere.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/includes/SpecialWhatlinkshere.php b/includes/SpecialWhatlinkshere.php index 277e279fdb..d84326a8ca 100644 --- a/includes/SpecialWhatlinkshere.php +++ b/includes/SpecialWhatlinkshere.php @@ -105,25 +105,24 @@ class WhatLinksHerePage { } if ( $from ) { - $offsetCond = "page_id >= $from"; - } else { - $offsetCond = false; - } - $options['ORDER BY'] = 'page_id'; + $from = (int)$from; // just in case + $tlConds[] = "tl_from >= $from"; + $plConds[] = "pl_from >= $from"; + } // Read an extra row as an at-end check $queryLimit = $limit + 1; $options['LIMIT'] = $queryLimit; - if ( $offsetCond ) { - $tlConds[] = $offsetCond; - $plConds[] = $offsetCond; - } $fields = array( 'page_id', 'page_namespace', 'page_title', 'page_is_redirect' ); + $options['ORDER BY'] = 'pl_from'; $plRes = $dbr->select( array( 'pagelinks', 'page' ), $fields, $plConds, $fname, $options ); + + $options['ORDER BY'] = 'tl_from'; $tlRes = $dbr->select( array( 'templatelinks', 'page' ), $fields, $tlConds, $fname, $options ); + if ( !$dbr->numRows( $plRes ) && !$dbr->numRows( $tlRes ) ) { if ( 0 == $level && !isset( $this->namespace ) ) { // really no links to here -- 2.20.1